import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/14 16:26
 * @description
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Set<Integer> set = new HashSet<>();
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int a = sc.nextInt();
                set.add(a);
            }
            int n = sc.nextInt();
            for (int i = 0; i < n; i++) {
                int a = sc.nextInt();
                set.add(a);
            }
            List<Integer> list = new ArrayList<>(set);
            Collections.sort(list);
            String ans = "";
            for (Integer a : list) {
                ans += a;
            }
            System.out.println(ans);
        }
    }
}
